﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;




    public class datThoiKhoaBieu
    {
        SqlCommand cmd;
        SqlDataReader dr;
        public List<entThoiKhoaBieu> getByTuan(int tuan, string lop)
        {
            string constr = System.Configuration.ConfigurationManager.ConnectionStrings["conStr2"].ConnectionString;
            SqlConnection sqlConnection = new SqlConnection(constr);
            sqlConnection.Open();
            cmd = new SqlCommand("sp_TKBGetByTuan", sqlConnection);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter[] sqla = new SqlParameter[2];
            sqla[0] = new SqlParameter("Tuan", DbType.String);
            sqla[1] = new SqlParameter("malop", DbType.Int16);
            sqla[0].Value = tuan;
            sqla[1].Value = lop;
            cmd.Parameters.AddRange(sqla);
            dr = cmd.ExecuteReader();
            List<entThoiKhoaBieu> lst = new List<entThoiKhoaBieu>();
            entThoiKhoaBieu entTKB;
            while (dr.Read())
            {
                entTKB = new entThoiKhoaBieu();
                entTKB.TH = int.Parse(dr["th"].ToString());
                entTKB.GD = dr["GD"].ToString();
                entTKB.Tiet = int.Parse(dr["tiet"].ToString());
                entTKB.Mon = dr["mon"].ToString();
                //entTKB.NgayDau = dr["NgayDau"].ToString();
                //entTKB.NgayCuoi = dr["NgayCuoi"].ToString();
                entTKB.Lop = dr["lop"].ToString();
                lst.Add(entTKB);
            }
            dr.Close();
            sqlConnection.Close();
            return lst;
        }
        public int update(string path, string path2)
        {
            string constr = System.Configuration.ConfigurationManager.ConnectionStrings["conStr2"].ConnectionString;
            SqlConnection sqlConnection = new SqlConnection(constr);
            sqlConnection.Open();
            cmd = new SqlCommand("sp_ThoiKhoaBieuUpDate", sqlConnection);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter[] sqla = new SqlParameter[2];
            sqla[0] = new SqlParameter("path", DbType.String);
            sqla[0].Value = path;
            sqla[1] = new SqlParameter("path2", DbType.String);
            sqla[1].Value = path2;
            cmd.Parameters.AddRange(sqla);
            cmd.ExecuteNonQuery();
            sqlConnection.Close();
            return 1;
        }
    }

